<template>
  <div class="goodsItemContainer">
    <div
      @click="goDetail(goods.id)"
      class="goodsItem"
      :key="index1"
      v-for="(goods, index1) in itemList"
    >
      <!-- <img
              :src="goods.listPicUrl"
              alt=""
            /> -->

      <van-image width="100%" radius="15px" lazy-load :src="goods.listPicUrl" />

      <p class="goods_title">{{ goods.name }}</p>
      <p class="price">￥{{ goods.retailPrice }}</p>
      <p class="sale_active">最高可100%返还</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsList",
  props: ["itemList"],
  methods: {
    goDetail(id) {
      this.$router.push({
        path: "/detail",
        query: { id },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.goodsItemContainer {
  background: white;
  display: flex;
  flex-wrap: wrap;
  // justify-content: space-evenly;
  .goodsItem {
    margin-left: 3%;
    margin-bottom: 20px;
    width: 45%;
    img {
      width: 100%;
      border-radius: 15px;
    }
    p {
      font-size: 15px;
    }
    .price {
      color: red;
      margin: 5px 0;
      font-weight: 700;
    }
    .sale_active {
      background: #ffe9eb;
      padding: 5px 10px;
      border-radius: 8px;
      color: red;
    }
    .goods_title {
      overflow: hidden;
      text-overflow: ellipsis;

      /*设置webkit盒子模型*/
      display: -webkit-box;
      /* 设置纵向对齐 */
      -webkit-box-orient: vertical;
      /* 设置多少行有省略号 */
      -webkit-line-clamp: 2;
    }
  }
}
</style>